﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace CAATS_Registration
{
    public partial class caats_step2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
                return;
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            if (0 == DropDownList1.SelectedIndex)
            {
                dataRecord.Instance().m_bPersonal = true;
                dataRecord.Instance()._strMemberCnt = DropDownList_slectMC2.SelectedValue;
                dataRecord.Instance().organization = txtPersonal.Text;
                if ( txtPersonal.Text.Equals(""))
                {
                    Response.Write(" <script laguage= 'javascript'> alert( 'Please input the organization  ! '); </script> ");
                    return;
                }
            }
            else
            {
                dataRecord.Instance().m_bPersonal = false;
                dataRecord.Instance().organization = DropDownList1.SelectedItem.Text;

                dataRecord.Instance()._strMemberCnt = DropDownList_SelMemberCnt.SelectedValue;

            }
            Int32 nCnt = Convert.ToInt32(dataRecord.Instance()._strMemberCnt);
            if (0 == nCnt)
            {
                Response.Write(" <script laguage= 'javascript'> alert( 'Please select the number of participants ! '); </script> ");
                return;
            }
            Server.Transfer("caats_step3.aspx?name=step3", true);

        }

        protected void Back_Click(object sender, EventArgs e)
        {

            Server.Transfer("Default.aspx?name=step1", true);

        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            DropDownList1.SelectedIndex = 0;
            //DropDownList_Nationality.SelectedIndex = 0;
            DropDownList_SelMemberCnt.SelectedIndex = 0;

            dataRecord.Instance().organization = "";
            dataRecord.Instance().country = "";
            dataRecord.Instance()._strMemberCnt = "0";
            //RadioButtonList_SelectContry.SelectedIndex = -1;
            //dataRecord.Instance().isInChina = true;
            //dataRecord.Instance().organization = "Unknow";
        }

        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            DropDownList _dl = (DropDownList)sender;

            dataRecord.Instance().organization = _dl.SelectedItem.Text;
            int idx = _dl.SelectedIndex;

            if (idx != 0)
            {
                DropDownList_slectMC2.Enabled = false;
                txtPersonal.Enabled = false;
                dataRecord.Instance().m_bPersonal = false;
            }
            else
            {
                DropDownList_slectMC2.Enabled = true;
                txtPersonal.Enabled = true;
                dataRecord.Instance().m_bPersonal = true;

            }
            //Response.Write(" <script   language=JavaScript> alert( 'Your   message '); </script> "); 
            //Response.Write(dataRecord.Instance().organization); 

        }

        protected void DropDownList_Nationality_SelectedIndexChanged(object sender, EventArgs e)
        {
            //DropDownList _dl = (DropDownList)sender;
            //int idx = _dl.SelectedIndex;
            //dataRecord.Instance().country = _dl.SelectedItem.Text;
        }

        protected void DropDownList_SelMemberCnt_SelectedIndexChanged(object sender, EventArgs e)
        {
            // DropDownList _dl = (DropDownList)sender;
            // int idx = _dl.SelectedIndex;
            //dataRecord.Instance()._strMemberCnt = _dl.SelectedValue;

        }

        protected void txtPersonal_TextChanged(object sender, EventArgs e)
        {
            dataRecord.Instance().organization = txtPersonal.Text;
        }

        protected void DropDownList_slectMC2_SelectedIndexChanged(object sender, EventArgs e)
        {
            DropDownList _dl = (DropDownList)sender;
            int idx = _dl.SelectedIndex;
            dataRecord.Instance()._strMemberCnt = _dl.SelectedValue;
            dataRecord.Instance().m_bPersonal = true;
        }

    }
}
